package com.nantian.logic.controller.mainControl.busiControl;

import com.cuit.springboot.gdao.user.BusinessMapper;
import com.cuit.springboot.gdao.common.DictMapper;
import com.cuit.springboot.gentry.user.Business;
import com.nantian.logic.utils.UniversalResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/*
 *针对企业信息进行维护和查询
 */
@RestController
@RequestMapping(value = "/busi")
public class BusiController {

    @Autowired
    BusinessMapper busiMapper;
    @Autowired
    DictMapper dictMapper;

    @PostMapping(value="/selByUserid")
    public UniversalResult<List> selectByUserid(@RequestBody Business business){
        List list=new ArrayList();
        Business busi=busiMapper.selectByUserid(business.getUserid());
        list.add(busi);
        list.add(dictMapper.selectBytype("busilevel"));
        list.add(dictMapper.selectBytype("busiscale"));
        return new UniversalResult<List>(UniversalResult.SUCCESS,"查询企业信息成功",list);
    }

    @PostMapping(value="/save")
    public UniversalResult saveBusinessInfo(@RequestBody Business business){
        busiMapper.updateByPrimaryKey(business);
        return new UniversalResult(UniversalResult.SUCCESS,"保存企业信息成功");
    }
}